import { createRouter, createWebHistory } from 'vue-router'
import NotFound from '../views/NotFound.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/Home.vue'),
      meta: {
        background: '#ffffff'
      }
    },
    {
      path: '/analysis',
      name: 'analysis',
      component: () => import('../views/Analysis.vue'),
      meta: {
        background: '#f8fafc'
      }
    },
    {
      path: '/:pathMatch(.*)*',
      name: 'not-found',
      component: NotFound,
      meta: {
        background: '#ffffff'
      }
    }
  ],
  scrollBehavior(_, __, savedPosition) {
    if (savedPosition) {
      return savedPosition
    }
    return { top: 0 }
  }
})

// Navigation guards
router.beforeEach((to, from, next) => {
  console.log(`Navigation from ${from.path} to ${to.path}`);
  next()
})

export default router